package com.atguigu.common.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * ClassName: PageMPConfiguration
 * Package: com.atguigu.common.config
 * Description: 配置MybatisPlus分页插件（本质上是拦截器）
 *
 * @Author 梅超凡
 * @Create 2024/11/13 17:10
 * @Version 1.0
 */
@Component
public class PageMPConfiguration {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        //配置MybatisPlus分页插件（本质上是拦截器）
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //添加分页拦截器
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
